< previous page page_164 next page >

Page 164
Solution 6
Icon Fix This One
Part of the trick to solving this puzzle is to step through the code. The LoadIcon function is returning 0, indicating that the icon failed to load. If you are running Windows NT, the GetErrorString function in the ErrString.bas module retrieves a description based on the LastError result retrieved from the Err.LastDllError property.
Why isn't LoadIcon working?
To understand the problem, let's walk through some of the C header code and see exactly how the icon constants are defined. Let's start with the constant definitions:
#ifdef RC INVOKED
#define IDI_APPLICATION     32512
#define IDI_HAND            32513
#define IDI_QUESTION        32514
#define IDI_EXCLAMATION     32515
#define IDI_ASTERISK        32516
#if(WINVER >= 0x0400)
#define IDI_WINLOGO         32517
#endif /* WINVER >= 0x0400 */
#else
#define IDI_APPLICATION     MAKEINTRESOURCE(32512)
#define IDI_HAND            MAKEINTRESOURCE(32513)
#define IDI_QUESTION        MAKEINTRESOURCE(32514)
#define IDI_EXCLAMATION     MAKEINTRESOURCE(32515)
#define IDI_ASTERISK        MAKEINTRESOURCE(32516)
#if(WINVER >= 0x0400)
#define IDI_WINLOGO         MAKEINTRESOURCE(32517)
#endif /* WINVER >= 0x0400 */
#endif /* RC INVOKED */
The #ifdef RC_INVOKED constant is true if the header file is being invoked from a resource compilera special compiler that combines various types of resources, such as icon and bitmap files, into a format that can be linked into an executable file. We're much more concerned with the way the constants are called from the C compiler itself, so everything within the RC_INVOKED block can be ignored. This leaves us with the following definitions:

 
< previous page page_164 next page >